package control.hall
{
	import control.panel.PanelControl;
	
	import events.LoginEvent;
	
	import flash.events.Event;
	
	import view.components.ModulLoader;
	import view.hall.RankModul;
	
	public class RankModulControl extends PanelControl
	{
		private var modulLoader:ModulLoader;
		private var isLogin:Boolean;
		
		public function RankModulControl()
		{
			initRankModul();
			initModulLoader();
			initListener();
			startLoad();
		}
		
		private function initListener():void
		{
			_model.loginModel.addEventListener(LoginEvent.SUCCESS,onLoginSuccess);
			modulLoader.addEventListener(Event.COMPLETE,onLoadComplete);
		}
		
		private function onLoadComplete(e:Event):void
		{
			/*if (isLogin)
			{
				modulLoader.content.load();
			}
			*/
			modulLoader.content.load();
		}
		
		private function onLoginSuccess(event:LoginEvent):void
		{
			/*if ( modulLoader.isComplete)
			{
				modulLoader.content.load();
			}
			isLogin = true;*/
		}
		
		private function startLoad():void
		{
			modulLoader.load("Rank.swf");
		}
		
		private function initModulLoader():void
		{
			modulLoader = new ModulLoader(750,200);
			modulLoader.addEventListener(Event.COMPLETE,onComplete);
			_view.rankModul.addChild(modulLoader);
		}
		
		private function onComplete(event:Event):void
		{
			modulLoader.content.init();
		}
		
		private function initRankModul():void
		{
			_view.rankModul = new RankModul();
			_view.rankModul.y = 580;
			_view.stage.addChild(_view.rankModul);
		}
	}
}